package com.gticket.cinemauser.mapper;

import com.gticket.cinemauser.pojo.Users;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

public interface UsersMapper {

    /**
     * 通过用户名查询用户
     * @param user user对象，需传入用户名、影院名
     * @return
     */
    @Select("select user_id,user_name,user_phone,user_password,user_score,role_id,flag " +
            "from ${databaseName}.users where user_name=#{user_name} and flag = 0")
    Users selectUserByUser_name(Users user);

    /**
     * 添加用户
     * @param user  user对象，需传入用户名、密码、影院名
     * @return int 新增用户的Id
     */
    @Insert("insert into ${databaseName}.users(user_name,user_phone,user_password) values(#{user_name},#{user_phone},#{user_password})")
    @Options(useGeneratedKeys = true,keyProperty = "user_id",keyColumn = "user_id")
    int addUser(Users user);
}
